﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using CookComputing.XmlRpc;
using System.Collections;

namespace CYTools.Util
{
    public class IProxy
    {
        /// <summary>
        /// common
        /// </summary>
        [XmlRpcUrl("http://115.28.79.144:8089/xmlrpc/common")]
        public interface ICommon : IXmlRpcProxy
        {
            /// <summary>
            /// 用户登录
            /// </summary>
            /// <param name="dbName">db名</param>
            /// <param name="userName">用户名</param>
            /// <param name="password">密码</param>
            /// <returns>用户id</returns>
            [XmlRpcMethod]
            int login(string dbName, string userName, string password);
        }

        /// <summary>
        /// search 方法
        /// </summary>
        [XmlRpcUrl("http://127.0.0.1:8079/xmlrpc/2/object")]
        public interface ISearch : IXmlRpcProxy
        {

            /// <summary>
            /// search方法：获取对象的id列表（ids）
            /// </summary>
            /// <param name="dnName">数据库名</param>
            /// <param name="uid">用户id</param>
            /// <param name="pwd">密码</param>
            /// <param name="objName">对象名</param>
            /// <param name="method">方法名（固定为search）</param>
            /// <param name="param1">方法为search时为过滤条件，格式：[[["name","=","zhangsan"],["age",">=",20]]]</param>
            /// <returns>ids</returns>
            [XmlRpcMethod]
            object[] execute(string dnName, int uid, string pwd, string objName, string method, object[] filter);
        }
        /// <summary>
        /// read方法
        /// </summary>
        [XmlRpcUrl("http://127.0.0.1:8079/xmlrpc/2/object")]
        public interface IRead : IXmlRpcProxy
        {
            /// <summary>
            /// read方法：获取对象明细
            /// </summary>
            /// <param name="dbName">数据库名</param>
            /// <param name="uid">用户id</param>
            /// <param name="pwd">密码</param>
            /// <param name="objName">对象名</param>
            /// <param name="method">方法(固定为read)</param>
            /// <param name="ids">获取对象ids</param>
            /// <param name="fields">获取的对象字段，格式:{'fields':['product_id','product_name','product_format','default_code']}</param>
            /// <returns>对象列表</returns>
            [XmlRpcMethod]
            object[] execute(string dbName, int uid, string pwd, string objName, string method, object[] ids, object[] fields);
        }

        /// <summary>
        /// 调用方法接口
        /// </summary>
        [XmlRpcUrl("http://192.168.254.201:8069/xmlrpc/2/object")]
        //[XmlRpcUrl("http://115.28.79.144:8089/xmlrpc/2/object")]
        public interface IMethod : IXmlRpcProxy
        {
            /// <summary>
            /// read方法：获取对象明细
            /// </summary>
            /// <param name="dbName">数据库名</param>
            /// <param name="uid">用户id</param>
            /// <param name="pwd">密码</param>
            /// <param name="objName">对象名</param>
            /// <param name="method">方法(固定为read)</param>
            /// <param name="param">json字符串，格式:{"name":"value"}</param>
            /// <returns>对象列表</returns>
            [XmlRpcMethod]
            object execute(string dbName, int uid, string pwd, string objName, string method, string param);
        }
    }
}
